<?php
!defined('IN_FRAME') && die('404 Page');
class m_slide extends Model {
        
    public function __construct() {
        $this->table = 't_slide';
        parent::__construct();
    }
    
    private function setCacheStorage() {
        phpFastCache::$storage = 'files';
        phpFastCache::$securityKey = 'slide';
        phpFastCache::$path = CACHES_PATH;
    }
    
    public function getAll() {
        $this->setCacheStorage();
        $re = phpFastCache::get('slide');
        if (!$re) {
            $re = $this->select(array('rec_status' => 1), '*', 'ORDER BY `list_order`');
            phpFastCache::set('slide', $re, 86400000);
        }
        !$re && $re = array();
        return $re;
    }
    
    private function refresh() {
        $this->setCacheStorage();
        phpFastCache::set('slide', $this->select(array('rec_status' => 1), '*', 'ORDER BY `list_order`'), 86400000);
    }
    
    public function update($arrSet, $arrWhere) {
        $re = parent::update($arrSet, $arrWhere);
        $this->refresh();
        return $re;
    }
    
    public function insert($arrData) {
        $re = parent::insert($arrData);
        $this->refresh();
        return $re;
    }
    
    public function delete($arrWhere) {
        $re = parent::delete($arrWhere);
        $this->refresh();
        return $re;
    }
    
}